package org.example.algorithm;

import java.util.Stack;

public class UseStackImplementQueueSolution {
    public static void main(String[] args) {

    }
}

class MyQueue {
    private Stack<Integer> stackLeft;
    private Stack<Integer> stackRight;

    public MyQueue() {
        stackLeft = new Stack<>();
        stackRight = new Stack<>();
    }

    public void push(int x) {
        int size = stackLeft.size();
        for (int i=0;i<size;i++) {
            stackRight.push(stackLeft.pop());
        }
        stackLeft.push(x);
        for (int i=0;i<size;i++) {
            stackLeft.push(stackRight.pop());
        }

    }

    public int pop() {
        return stackLeft.pop();
    }

    public int peek() {
        return stackLeft.peek();
    }

    public boolean empty() {
        return stackLeft.isEmpty();
    }
}
